package com.aiyige.page.publish.photo.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.aiyige.location.model.LocationData;
import com.aiyige.page.interest.model.Interest;
import com.aiyige.page.publish.selectinterest.model.PublishInterestItem;
import com.aiyige.page.publish.tag.model.TagItem;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2017/11/17.
 */

public class PhotoFormModel implements Parcelable {
    String title;
    List<Interest> interestList;
    List<Interest> industryList;
    LocationData locationData;
    List<PublishPhotoItem> publishPhotoItemList;
    long releaseData;
    String introduction;

    public PhotoFormModel() {
    }

    private PhotoFormModel(Builder builder) {
        setTitle(builder.title);
        setInterestList(builder.interestList);
        setIndustryList(builder.industryList);
        setLocationData(builder.locationData);
        setPublishPhotoItemList(builder.publishPhotoItemList);
        setReleaseData(builder.releaseData);
        setIntroduction(builder.introduction);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<Interest> getInterestList() {
        return interestList;
    }

    public void setInterestList(List<Interest> interestList) {
        this.interestList = interestList;
    }

    public List<Interest> getIndustryList() {
        return industryList;
    }

    public void setIndustryList(List<Interest> industryList) {
        this.industryList = industryList;
    }

    public LocationData getLocationData() {
        return locationData;
    }

    public void setLocationData(LocationData locationData) {
        this.locationData = locationData;
    }

    public List<PublishPhotoItem> getPublishPhotoItemList() {
        return publishPhotoItemList;
    }

    public void setPublishPhotoItemList(List<PublishPhotoItem> publishPhotoItemList) {
        this.publishPhotoItemList = publishPhotoItemList;
    }

    public long getReleaseData() {
        return releaseData;
    }

    public void setReleaseData(long releaseData) {
        this.releaseData = releaseData;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public static final class Builder {
        private String title;
        private List<Interest> interestList;
        private List<Interest> industryList;
        private LocationData locationData;
        private List<PublishPhotoItem> publishPhotoItemList;
        private long releaseData;
        private String introduction;

        private Builder() {
            title = "";
            interestList = new LinkedList<>();
            industryList = new LinkedList<>();
            locationData = new LocationData();
            publishPhotoItemList = new LinkedList<>();
            introduction = "";
        }

        public Builder title(String val) {
            title = val;
            return this;
        }

        public Builder interestList(List<Interest> val) {
            interestList = val;
            return this;
        }

        public Builder industryList(List<Interest> val) {
            industryList = val;
            return this;
        }

        public Builder locationData(LocationData val) {
            locationData = val;
            return this;
        }

        public Builder publishPhotoItemList(List<PublishPhotoItem> val) {
            publishPhotoItemList = val;
            return this;
        }

        public Builder releaseData(long val) {
            releaseData = val;
            return this;
        }

        public Builder introduction(String val) {
            introduction = val;
            return this;
        }

        public PhotoFormModel build() {
            return new PhotoFormModel(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeTypedList(this.interestList);
        dest.writeTypedList(this.industryList);
        dest.writeParcelable(this.locationData, flags);
        dest.writeList(this.publishPhotoItemList);
        dest.writeLong(this.releaseData);
        dest.writeString(this.introduction);
    }

    protected PhotoFormModel(Parcel in) {
        this.title = in.readString();
        this.interestList = in.createTypedArrayList(Interest.CREATOR);
        this.industryList = in.createTypedArrayList(Interest.CREATOR);
        this.locationData = in.readParcelable(LocationData.class.getClassLoader());
        this.publishPhotoItemList = new ArrayList<PublishPhotoItem>();
        in.readList(this.publishPhotoItemList, PublishPhotoItem.class.getClassLoader());
        this.releaseData = in.readLong();
        this.introduction = in.readString();
    }

    public static final Creator<PhotoFormModel> CREATOR = new Creator<PhotoFormModel>() {
        @Override
        public PhotoFormModel createFromParcel(Parcel source) {
            return new PhotoFormModel(source);
        }

        @Override
        public PhotoFormModel[] newArray(int size) {
            return new PhotoFormModel[size];
        }
    };
}
